We analyze a general model of weighted graphs, introduced by de Panafieu and Ravelomanana (2014) and similar to the "inhomogeneous graph model" of S\"oderberg (2002). Each vertex receives a "type" among a set of $q$ possibilities as well as a "weight" corresponding to this type, and each edge is weighted according to the types of the vertices it links. The weight of the graph is then the product of the weights of its vertices and edges. We investigate the sum of the weights of such graphs and prove that when the number of edges is small, almost all of them contain no component with more than one cycle. Those results allow us to give a new proof in a more general setting of a theorem of Wright (1961) on the enumeration of properly colored graphs. We also discuss applications related to social networks.